<?php

namespace api\modules\v1\controllers;

use Yii;
use common\models\NewsCategory;
use common\components\ETRestController;
use yii\data\ActiveDataProvider;

class DemoController extends ETRestController {

    public $modelClass = 'common\models\NewsCategory';
    
    public function actionCateLists() {
        $categories = NewsCategory::find()
                ->where('status=:status', [':status' => NewsCategory::STATUS_ACTIVE])
                ->all();
        $categoryArr = [];
        foreach ($categories as $category) {
            $categoryArr[] = $category->toArray([], ['products']);
        }
        return $this->jsonSuccess(['categories' => $categoryArr]);
    }

}
